package com.ocom.company.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.human.EntityResourceApi;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoResourceApi extends BaseMapper<EntityResourceApi> {

    @Select({"<script>",
            "select  a.* ,p.permission \n" +
                    "FROM resource_api a inner join role_permission p on a.id=p.page_id \n" +
                    "where p.role=#{role} " +
                    "and p.api_id<![CDATA[<=]]>0 " +
                    "and p.permission &gt; 0 " +
                    "and a.api_app_code &lt;&gt; '' " +
                    "order by a.id" +
                    "</script>"})
    public List<EntityResourceApi> getPageList(Integer role);

    @Select({"<script>",
            "select  a.* ,p.page_id \n" +
                    "FROM resource_api a inner join role_permission p on a.id=p.page_id \n" +
                    "where p.role=#{role} " +
                    "and p.permission &gt; 0 " +
                    "and p.api_id &gt; 0 " +
                    "order by p.page_id,p.api_id" +
                    "</script>"})
    public List<EntityResourceApi> getButtoneList(Integer role);
}
